package com.example.es.utils;

import lombok.SneakyThrows;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/10/15 21:24
 */
public class ClimbZhenUtil
{
    @SneakyThrows
    public static void main(String[] args)
    {
        String url = "http://www.zhenai.com/zhenghun";
        Document document = Jsoup.parse(new URL(url), 30000);
        Elements elements = document.getElementsByClass("city-list");
        List<String> list = new ArrayList<>();
        for (Element element : elements)
        {
            Elements a = element.getElementsByTag("a");
            for (Element element1 : a)
            {
                String text = element1.text();
//                System.out.println(text);
                list.add(text);
            }
        }
        System.out.println(list.toString());
        System.out.println(list.size());
    }
}
